package com.happypets.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.happypets.model.UserBean;
import com.happypets.servicesImpl.UserServiceImpl;

/**
 * Servlet implementation class UpUserPass
 */
public class UpUserPass extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpUserPass() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String id = request.getParameter("id");
		
		UserServiceImpl userSer = new UserServiceImpl();
		
		UserBean ub = userSer.getUserBeanById(id);
		
//		request.setAttribute("user", ub);
		
//		request.getRequestDispatcher("/web/upPass.jsp").forward(request, response);
		response.sendRedirect(request.getContextPath()+"/web/upPass.jsp?name="+ub.getUserName());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
